package com.shopping.mall.core.module.paypal.service;


import com.paypal.api.payments.Payment;
import com.paypal.base.rest.PayPalRESTException;
import com.shopping.mall.base.http.Result;
import com.shopping.mall.core.module.order.entity.Order;
import com.shopping.mall.core.module.paypal.entity.PaymentModel;
import org.springframework.transaction.annotation.Transactional;

import java.io.UnsupportedEncodingException;

/**
 * @program: 
 * @description:
 * @author: 
 * @create: 
 **/
public interface PaymentService {

    /**
     * 创建支付
     * @param paymentModel
     * @param cancelUrl
     * @param successUrl
     * @return
     * @throws PayPalRESTException
     */
    Payment createPayment(PaymentModel paymentModel, String cancelUrl, String successUrl) throws PayPalRESTException, UnsupportedEncodingException;

    /**
     * 执行支付
     * @param paymentId
     * @param payerId
     * @return
     * @throws PayPalRESTException
     */
    Payment executePayment(String paymentId, String payerId) throws PayPalRESTException, UnsupportedEncodingException;

    Result<Object> refund(Order order);

    @Transactional
    Result<Object> refundAdmin(Order order);
}

